<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>SAP查询系统—江苏弘仁供应链管理有限公司 - www.wholeline.cn</title>
	<%@ include file="/common/meta.jsp" %>
	<meta content="newuser" name="activemenu" />
	<link href="${ctx}/css/base.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/master.css" rel="stylesheet" type="text/css" />
	<script src="${ctx}/js/jquery.js" type="text/javascript"></script>
	<script src="${ctx}/js/table.js" type="text/javascript"></script>
	<link href="${ctx}/validate/jquery.validate.css" type="text/css" rel="stylesheet"/>
	<script src="${ctx}/validate/jquery.validate.js" type="text/javascript"></script>
	<script src="${ctx}/validate/messages_cn.js" type="text/javascript"></script>
	<script>
	$(document).ready(function() {
		var rolestr = $('#userRole').val();
		if(rolestr != null && roles != ""){
			var roles = rolestr.split(",");
			for(var role in roles){
				alert(role);
			}
		}
		
		jQuery.validator.addMethod("validateUsername", function(value, element) {
			var username = $.trim($("#username").val());
			var re =/^[0-9A-Za-z]{1,}$/ ;
			if (!re.test(username)){ 
 		    	return false;
 		    }
 		    return true;
		}, "由英文字母和数字组成！");
		jQuery.validator.addMethod("validateidNumber",function(value,element,params){
 	 		var card=$.trim($("#idNumber").val());
  			if(value!=''){
	 			// 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X
	 			var reg = /(^\d{15}$)|(^\d{17}(\d|X)$)/;
	 			if(reg.test(card) === false)
	 			{
	 				return false;
	 			}
  			}
 			return true;
		},"身份证号格式错误");
		// 手机号码验证    
		jQuery.validator.addMethod("isMobile", function(value, element) {    
		  var length = value.length;    
		  return this.optional(element) || (length == 11 && /^13\d{9}$/.test(value)||(/^15[0-35-9]\d{8}$/.test(value))|| (/^18[025-9]\d{8}$/.test(value)));   
		}, "请正确填写手机号码");    
		  
		// 电话号码验证    
		jQuery.validator.addMethod("isPhone", function(value, element) {    
		  var tel = /^(\d{3,4}-?)?\d{7,9}$/g;    
		  return this.optional(element) || (tel.test(value));    
		}, "请正确填写电话号码");
		$("#inputForm").validate({
			rules: {
				'user.enname': {
					minlength:4,
					maxlength:18,
				},
				'user.idNumber': {
					minlength:15,
					maxlength:18,
					validateidNumber:true
				},
				'user.name': {
					maxlength:20,
				},
				'user.company': {
					maxlength:50,
				},
				'user.contact': {
					maxlength:20,
				},
				'user.mobile': {
					isMobile:true
				},
				'user.telephone': {
					isPhone:true
				}
			},
			errorPlacement: function(error, element) {   
		        if (document.getElementById("error_"+element.attr("name")))  {
		            error.appendTo("#error_"+element.attr("name"));  
		        }
		        else {
		            error.insertAfter(element); 
		        }
		    },
		    errorElement: "strong"
		});
	});
	
	</script>
</head>
<body>
<!--左边tab-->
<jsp:include page="/common/header.jsp" />
	<div class="main_wrap1">
	<div class="main_all">
	<!--左边tab-->
		<div class="left_main">
		  <jsp:include page="/common/menu.jsp" />
		</div>
		<!--左边tab结束-->
<!--左边tab结束-->
<!--右边-->
<div class="right_box">
<form id="inputForm" action="${ctx}/sys/user!save.action" method="post" >
	<input type="hidden" name="id" value="${id}"/>
	<div class="top_serach_box">
        <ul class="form">
        	<li><div style="width:100px;float:left;"><label>用户角色</label></div><div style="float:left;width:500px;"><s:radio  list="@cn.dy.sbo.contants.Constants@ROLE_MAP" listKey="key" listValue="value"
				name="rolecode" id="rolecode" value="rolecode" /></div>
				<input type="hidden" name="user.role" value="${user.role}" id="userRole"/>
			</li>
		    <li style="clear:both"><label>用户名</label><input id="username" name="user.username" value="${user.username}"  type="text" style="width:200px;" readonly="readonly" /></li>
		    <li><label>英文名</label><input id="enname" name="user.enname" value="${user.enname}" type="text" style="width:200px;" /></li>
		    <li><label>身份证号</label><input id="idNumber" name="user.idNumber" value="${user.idNumber}" type="text" style="width:200px;" /></li>
		    <li><label>姓名</label><input id="name" name="user.name" value="${user.name}" type="text" style="width:200px;" /></li>
		    <li><label>工作单位</label><input id="company" name="user.company" value="${user.company}" type="text" style="width:200px;" /></li>
		    <li><label>联系人</label><input id="contact" name="user.contact" value="${user.contact}" type="text" style="width:200px;" /></li>
		    <li><label>手机</label><input id="mobile" name="user.mobile" value="${user.mobile}" type="text" style="width:100px;" /></li>
		    <li><label>固定电话</label><input id="telephone" name="user.telephone" value="${user.telephone}" type="text" style="width:100px;" /></li>
	    </ul>
		<p class="button_box"><input type="submit" value="保   存" />&nbsp;&nbsp;
		<input type="button" value="取  消" onclick="javascript:history.back();" />
		</p>
	</div>
</form>
</div>
<!--右边结束-->
</div> <!-- content  end-->
</div><!-- wrapper  end-->  
</body>
</html>